<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/templates/_template.xhtml">

        <ui:define name="titulo">

            <h3>Lançamento de Despesas</h3>

        </ui:define>

        <ui:define name="conteudo">
            <p:growl autoUpdate="true" />
            <h:form>

                <p:messages id="messages" autoUpdate="true" />
                <p:fieldset legend="Dados da Operação - Despesa" styleClass="fieldsetSms">
                    <h:panelGrid columns="2">

                        <h:outputLabel value="Despesa:" for="despesa" styleClass="rotulos" />
                        <h:selectOneMenu id="despesa" value="#{despesaBean.despesaId}">
                            <f:selectItem itemLabel="Selecione a despesa" />
                            <f:selectItems value="#{despesaBean.listaDespesa}" var="despesa" 
                                           itemLabel="#{despesa.descricao}" itemValue="#{despesa.id}"/>  
                        </h:selectOneMenu>

                        <h:outputLabel value="Conta:" for="conta" styleClass="rotulos" />
                        <h:selectOneMenu id="conta" value="#{contaBean.contaId}">
                            <f:selectItem itemLabel="Selecione a despesa" />
                            <f:selectItems value="#{contaBean.listaContas}" var="conta" 
                                           itemLabel="#{conta.descricao}" itemValue="#{conta.id}"/>  
                        </h:selectOneMenu>

                        <h:outputLabel value="Valor:" for="valor" styleClass="rotulos"/>
                        <p:inputText id="valor" value="#{pagamentoBean.valor}" />
                
                        <h:outputLabel value="Data: "  for="dtpg" styleClass="rotulos"/>
                        <p:calendar id="dtpg"
                                    value="#{pagamentoBean.dataPagamento}"
                                    pattern="dd/MM/yyyy" timeZone="America/Sao_Paulo"
                                    required="true" 
                                    requiredMessage="Data obrigatória"  /> 
                        
                    </h:panelGrid>
                    <br />
                    <p:commandButton value="Confirmar" action="#{pagamentoBean.deduzConta()}" immediate="true"/>
                    <p:commandButton value="Cancelar" action="#{pagamentoBean.novo()}" immediate="true" />
                </p:fieldset>

            </h:form>
        </ui:define>
    </ui:composition>

</html>